﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MainGameModule.ViewModels;
using System.Collections.ObjectModel;
using MainGameModule.Models;
using BusinessObjects;

namespace MainGameModule
{
    public class BarResultsControl : Control
    {
        public static readonly DependencyProperty BinsCollectionProperty = DependencyProperty.Register( "BinsCollection", typeof( ObservableCollection<BinViewModel> ), typeof( BarResultsControl ), null );

        public BarResultsControl()
        {
            this.DefaultStyleKey = typeof( BarResultsControl );
        }

        public ObservableCollection<BinViewModel> BinsCollection
        {
            get { return ( ObservableCollection<BinViewModel> )GetValue( BinsCollectionProperty ); }
            set { SetValue( BinsCollectionProperty, value ); }
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.BinsCollection = RubbishBinsRepository.Instance.MapBinsCollection;
                        
            ListBox lb = this.GetTemplateChild( "BinItemsListBox") as ListBox;
            lb.ItemsSource = this.BinsCollection;

            ListBox lbContent = this.GetTemplateChild( "BinsContentListBox" ) as ListBox;
            lbContent.ItemsSource = this.BinsCollection;
        }
    }
}
